package com.molyfun.parents.activity.record.itemview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.TextView;

import com.molyfun.parents.R;
import com.molyfun.parents.rest.bean.RecordResponse;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by william(liuchao.hit@gmail.com).
 * Date:11/3/16.
 *
 * 此类为容器
 */
public class RecordTextView extends BaseRecordView{

    protected LayoutInflater layoutInflater;

    private Context context;

    @InjectView(R.id.record_text)
    TextView mRecordText;
    @InjectView(R.id.record_user)
    TextView mRecordUser;

    public RecordTextView(Context context, AttributeSet attrs, int defStyle) {
        this(context, attrs);
    }

    public RecordTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs);
    }

    public RecordTextView(Context context) {
        super(context);
        init(context, null);
    }

    private void init(Context context, AttributeSet attrs) {
        this.context = context;
        layoutInflater = LayoutInflater.from(context);
        layoutInflater.inflate(R.layout.widget_record_text, this);
        ButterKnife.inject(this);
    }

    /**
     * init view
     *
     */
    public void initData(RecordResponse.RecordBean recordBean) {
        if(recordBean != null){
            mRecordBean = recordBean;
            mRecordText.setText(recordBean.getContent());
            mRecordUser.setText(recordBean.getUsername());
            mRecordText.setOnLongClickListener(this);
        }
    }

}